package com.lier.gulimall.search.web;

import com.lier.gulimall.search.service.MallSearchService;
import com.lier.gulimall.search.vo.SearchParam;
import com.lier.gulimall.search.vo.SearchResult;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author liyd
 * @description
 * @date 2025/7/3 17:30
 */
@Controller
public class SearchController {

    @Resource
    private MallSearchService mallSearchService;

    @GetMapping(value =  "/list.html")
    public String listPage(SearchParam searchParam, Model model, HttpServletRequest request) {
        String queryString = request.getQueryString();
        // 设置原生查询条件
        searchParam.setQueryString(queryString);
        SearchResult result = mallSearchService.search(searchParam);
        model.addAttribute("result", result);
        return "list";
    }
}
